package org.example.netty.httpserver.json;

import com.alibaba.fastjson.JSON;
import lombok.Builder;
import lombok.Data;

@Data
@Builder
public class JSONData {
    private String content;

    private boolean fromServer;

    public JSONData() {}

    public JSONData(String content, boolean fromServer) {
        this.content = content;
        this.fromServer = fromServer;
    }

    public String toJson() {
        return JSON.toJSONString(this);
    }

    public static JSONData fromJson(String json) {
        return JSON.parseObject(json, JSONData.class);
    }
}
